package cn.wisco.web.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import cn.wisco.web.Constants;
import cn.wiscofile.pojo.BaseUser;
import cn.wiscofile.service.UsersService;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport implements ServletRequestAware{
	
	private javax.servlet.http.HttpServletRequest request;
	
	private BaseUser baseuser;
	
	private UsersService usersService;
	
	public String execute() {
		System.out.println("loginAction");
		//request =  ServletActionContext.getRequest();
		String userCode = baseuser.getUserCode();
		System.out.println("userCode: " + userCode);
		BaseUser loginUser = usersService.getUsers(userCode);
		System.out.println("loginUser:" + loginUser.getFullName());
		request.getSession().setAttribute(Constants.USER_KEY, loginUser);
		
		return SUCCESS;
	}

	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
	}

	public BaseUser getBaseuser() {
		return baseuser;
	}

	public void setBaseuser(BaseUser baseuser) {
		this.baseuser = baseuser;
	}

	public UsersService getUsersService() {
		return usersService;
	}

	public void setUsersService(UsersService usersService) {
		this.usersService = usersService;
	}
}
